/**
 * 业务员
 * Created by wenchuan.li on 2018/6/14 11:16.
 */
define(function () {

    var self,
        app = win.app,
        orderSubmitArg,
        searchData = {
            keyword: ''
        }
    ;

    var Customers = app.Module.extend({

        init: function () {
            self = this;
            self._super({
                _refreshAutoInit: true //自动加载刷新控件
            }, win);
            orderSubmitArg = self._pageParameters;
        },
        _initRefresh: function () { // 实例化刷新组件
            if (self._refreshIds.length == 0) {
                self._refreshIds = ['scroll1'];
            }
            this._super(win);
        },
        _refreshCb: function (goods) {// 刷新组件回调函授
            var _super = this._super;
            app.ajax({
                xurl: "sdhn/gwat153/listUser",
                xdata: {
                    page:goods.page+1,
                    limit: goods.limit,
                    keyword: searchData.keyword
                },
                cb: function (result) {
                    if (result.ok) {
                        var data = result.data;
                        goods.data.pushArray(data.data, goods.page == 0);

                        _super({
                            obj: goods,
                            dataLen: data.data.length,
                            nodata: '无业务员信息...'
                        });
                    }
                }
            });
        },
        _search:function (data) {
            searchData.keyword = data.keyword.trim();
            self._refresh();
        },
        _lazy: function () {
            this._super();
        },
        _ready: function () {
            Vue.component('ywysitem', {
                template: app.getByid(doc, 'ywyitem-template'),
                props: {
                    model: Array
                },
                methods: {
                    select:function (v) {
                        orderSubmitArg.cb(v);
                        app.back(1);
                    }
                }
            });
        }
    });

    new Customers();

});